package com.github.pig.admin.controller.sys;

import com.github.pig.admin.service.sys.SysDeptService;
import com.github.pig.admin.util.AjaxJson;
import com.github.pig.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lengleng
 * @date 2017/10/28
 */
@Slf4j
@RestController
@RequestMapping("/dept")
public class DeptController extends BaseController {
    private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
    @Autowired
    private SysDeptService deptService;


    /**
     * 查询企业信息
     *
     * @param companyId 当前用户信息
     * @return 用户名
     */
    @GetMapping("/getCompanyInfo")
    public AjaxJson getCompanyInfo(Integer companyId) {
        AjaxJson json = new AjaxJson();
        json.setSuccess(true);
        try{
            json.setObj(deptService.selectById(companyId));
        }catch(Exception e){
            json.setSuccess(false);
            json.setMsg("查询企业信息错误，"+e.getMessage());
            log.error("查询企业信息错误",e);
        }
        return json;
    }



}
